/*
 * RegistrationHandler.java
 *
 * Created on October 31, 2006, 3:23 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.asaga.tools;
import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;
import java.util.*;
/**
 *
 * @author jeremys
 */
public class RegistrationHandler {
    
private SystemClient_DBImpl sc;
private String errmsg;

    /** Creates a new instance of RegistrationHandler */
    public RegistrationHandler() {
    }
    
    public RegistrationHandler(HttpServletRequest request){
        errmsg = null;
        sc = new SystemClient_DBImpl();
        sc.setFname(request.getParameter("first_name"));
        sc.setLname(request.getParameter("last_name"));
        sc.setAddr1(request.getParameter("address_1"));
        sc.setAddr2(request.getParameter("address_2"));
        sc.setCity(request.getParameter("city"));
        sc.setState(request.getParameter("state"));
        sc.setZip(request.getParameter("zipcode"));
        sc.setEmail(request.getParameter("email_1"));
        sc.setPassword(request.getParameter("pass01"));
        sc.setFontColor(request.getParameter("fontColor"));
        }
    
    public boolean RegisterPerson(){
        if(this.sc.createProfile()==false){
            this.errmsg = this.sc.getErrorMessage();
            return false;
        }
        else{
            this.errmsg = this.sc.getErrorMessage();
            return true;
        }
    }
    
    public SystemClient_DBImpl getRegistrationInfo(){
        return this.sc;
    }
    
    public String getErrorMessage(){
        return this.errmsg;
    }
    
    public String getName(){
        return sc.getFname();
    }
    
     /** To get email information for Welcome Email Module on confirmation.jsp */
     public String getEmail(){
         return sc.getEmail();
    }
}
